<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>组件化</title>
    <script src="https://cdn.jsdelivr.net/npm/vue"></script>
</head>
<body>
<div id="app">
    <ul>
        <!-- 循环方式v-for 是循环数据data中list，v-bind:绑定组件化的props属性，-->
        <todo-item v-for="item in list" v-bind:todo="item" v-bind:key="item.id">{{item}}</todo-item>
    </ul>

</div>


<script>
    Vue.component("todo-item",{
        props:["todo"],//加TODO的属性，todo内值在template显示
        template:"<li>今天吃什么 {{todo.text}}</li>"
    });
    var app = new Vue({
        el: '#app',
        data: {
            list:[{id:'0',text:'鸡肉'},{id:'1',text:'蟹肉棒'},{id:'2',text:'虾滑'}]
        },
        methods:{
        }
    });

</script>
</body>
</html>
